using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace WindowsApplication1
{
    public partial class FormSearch : Form
    {
        private Database _db;
        public int _month = DateTime.Now.Month, _year = DateTime.Now.Year;
        public String djID = "0";
        public String TypeId = "0";
        public FormSearch()
        {
            InitializeComponent();
        }

        private void FormSearch_Load(object sender, EventArgs e)
        {
            _db = DatabaseFactory.CreateDatabase("Connection0");
            dataGridView1.DataSource = _db.ExecuteDataSet(CommandType.Text, String.Format("select [StoreDocuId], rq,[DocuNumber],B.Name from [StoreDocu] AS a left JOIN dbo.Customers AS B ON a.CustomerId = B.CustomerId where month(rq)={0} and year(rq)={1} and typeId={2} order by DocuNumber", _month.ToString(), _year.ToString(), TypeId)).Tables[0];
            Rectangle srec = Screen.GetBounds(this);
            this.DesktopLocation = new Point((srec.Width - this.Width) / 2, (srec.Height - this.Height) / 2);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
        }

        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            djID = dataGridView1.CurrentRow.Cells["id"].Value.ToString();
            
            this.Close();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}